<template>
  <aside class="btn-box">
    <el-row :gutter="15">
      <el-col :span="2">
        <el-button type="primary" size="mini" icon="el-icon-search" @click="searchBtn">查找</el-button>
        <search-dialog ref="search" @search="searchFun" />
      </el-col>
      <el-col :span="2">
        <el-button type="primary" size="mini" icon="el-icon-download">导出</el-button>
      </el-col>
      <el-col :span="2.5">
        <el-button type="primary" size="mini" icon="el-icon-top-right" @click="teamRemoveFun">团队迁移</el-button>
        <reset-team ref="resetTeam" />
      </el-col>
      <el-col :span="2.5">
        <el-button type="primary" size="mini" icon="el-icon-edit" @click="editFagent">修改上级</el-button>
        <reset-h ref="resetH" />
      </el-col>
    </el-row>
  </aside>
</template>

<script>
import searchDialog from './search-dialog'
import resetTeam from './teamReset'
import resetH from './reset-h'
export default {
  components: {
    searchDialog,
    resetTeam,
    resetH
  },
  props: {
    currentData: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  methods: {
    searchBtn() {
      this.$refs['search'].dialogShow = true
    },
    searchFun(val) {
      console.log(val)
      this.$emit('search', val)
    },
    teamRemoveFun() {
      // console.log(this.currentData)
      if (JSON.stringify(this.currentData) === '{}') {
        this.$message.info('请选择行！')
      } else {
        console.log(this.currentData)
        this.$refs['resetTeam'].form.brand_id = this.currentData.anent_brand_content[0].brand_id
        this.$refs['resetTeam'].form.anent_name = this.currentData.anent_name
        this.$refs['resetTeam'].form.code_num = this.currentData.anent_brand_content[0].code_num
        this.$refs['resetTeam'].dialogShow = true
      }
    },
    editFagent() {
      if (JSON.stringify(this.currentData) === '{}') {
        this.$message.info('请选择行！')
      } else {
        console.log(this.currentData)
        this.$refs['resetH'].form.brand_id = this.currentData.anent_brand_content[0].brand_id
        this.$refs['resetH'].form.anent_name = this.currentData.anent_name
        this.$refs['resetH'].form.code_num = this.currentData.anent_brand_content[0].code_num
        this.$refs['resetH'].form.old_code_num = this.currentData.anent_brand_content[0].anent_fid_content.code_num
        this.$refs['resetH'].dialogShow = true
      }
    }
  }
}
</script>

<style scoped>
  .el-button {
      width: 100%;
  }
</style>
